package com.alpha.eceasy.auth;

import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;

import java.util.Collection;

/**
 * 统一用户鉴权实体
 *
 * @param <T> 子模块用户实体
 */
@Setter
@Getter
@Slf4j
public class LoginUser<T> extends User {
    /**
     * 用来封装数据库查询出来的用户数据
     */
    private T userInfo;

    public LoginUser(String username, String password, Collection<? extends GrantedAuthority> authorities, T userInfo) {
        super(username, password, authorities);
        this.userInfo = userInfo;
    }

    public LoginUser(String username, String password, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities, T userInfo) {
        super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
        this.userInfo = userInfo;
    }
}